package com.openflag.bwicservice.controller;


import com.openflag.bwicservice.domain.Bwic;
import com.openflag.bwicservice.domain.Result;
import com.openflag.bwicservice.domain.ValueBondsRequest;
import com.openflag.bwicservice.repository.BwicRepository;
import com.openflag.bwicservice.service.TraderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

import static com.openflag.bwicservice.util.ResultUtil.success;

@RestController
@RequestMapping("/trader")
@CrossOrigin("*")
public class TraderController {


    @Autowired
    private TraderService traderService;

    @Autowired
    private BwicRepository bwicRepository;

    @GetMapping("/unvaluedlist/{clientId}")
    public Result<List<Bwic>> traderUnvaluedList(@PathVariable Long clientId){

        Result<List<Bwic>> result = traderService.traderUnvaluedList(clientId);

        return result;

    }

    @PostMapping("/valuebond")
    public Result<List<Bwic>> traderValueBond(@RequestBody ValueBondsRequest valueBondsRequest){

        return traderService.traderValueBonds(valueBondsRequest);

    }
    @GetMapping("/allList")
    public Result<List<Bwic>> getAllList(){
        Result<List<Bwic>> result = new Result<>();
        result = success(bwicRepository.getAllList());


        return result;

    }

}
